import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		username:'',
		orderList: []
	},
	mutations: {
		// 结算页商品数量更新
		uploadGoodsNum(stata,payload){
			stata.orderList.forEach((item)=>{
				if(item.id === payload.name){
					item.num = payload.value
				}
			})
		},
		// 储存用户名
		getUsername(stata,payload){
			stata.username = payload
		},
		// 添加购物车
		addShop(stata,payload){
			console.log(payload);
			stata.orderList = payload
		}
	},
	actions: {},
	getters: {

	}
})

export default store